<?php
class UserBase
{
	public $userid = 0;
	public $username = null;
	public $logined = false;
	public $mobile = "";
	public $truename = "";

	public $perms = array(
		'none' => false,
		'allow' => true, 	//登录相关，默认有权限
		'cake' => false,	//蛋糕管理
		'order' => false,	//订单管理
		'prod' => false,	//生产管理
		'dely' => false,	//配送管理
		'index' => false,	//主页
		'msg' => false,		//留言管理
		'user' => false,	//会员管理
		'log' => false,		//系统日志
		'adm' => false,		//管理员管理
	);

	function __construct()
	{
		if(!array_key_exists('admin', $_SESSION))
			return;
		$obj = $_SESSION['admin'];
		if($obj['logintime'] <=  time(0) - 1800)			//30分钟不操作登录失效
			return 0;
		$this->basedata = $obj;
		$this->userid= $obj['id'];
		$this->username = $obj['name'];
		$this->mobile = $obj['mobile'];
		$this->truename = $obj['truename'];
		$this->logined = true;
		//加载权限
		$this->perms = $obj['perms'];
	}
	
	function Active()
	{
		if($this->logined)
			$_SESSION['admin']['logintime'] = time(0);
	}
};

